﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using ZilLion.Service.Core.ConfigManager.Manager;
using ZilLion.Service.Core.DapperWrapper;
using ZilLion.Service.Core.DapperWrapper.SqlServer;

namespace ZilLion.Service.Core.WechatService.Domain
{
    public class WechatServiceContext2 : DefaultContext, IDbContext
    {
        private readonly string _connectionString;

        public WechatServiceContext2()
        {
            _connectionString =
                ZilLionConfigurationManager.GetConfigInstance<WechatServiceConfig>().DefaultConnection2;
        }

        public override string ContextName => "WechatServiceContext2";

        protected override string FomartConnectionString()
        {
            if (_connectionString.IsNullOrEmpty())
                return null;

            var appname = ContextName;
            var builder = new SqlConnectionStringBuilder(_connectionString)
            {
                ApplicationName = appname
            };
            return builder.ToString();
        }
    }
}
